package cn.chenhuanming.chuanzhi.controller;

import cn.chenhuanming.chuanzhi.service.ShareService;
import cn.chenhuanming.chuanzhi.service.StaffService;
import cn.chenhuanming.chuanzhi.util.entity.Staff;
import cn.chenhuanming.chuanzhi.util.entity.view.JsonPage;
import cn.chenhuanming.chuanzhi.util.entity.view.View;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2017-05-06.
 */
@RestController
public class FrontEndDataController {

    @Autowired
    ShareService shareService;

    @Autowired
    StaffService staffService;

    @JsonView(View.StaffListView.class)
    @GetMapping("/staff")
    Page<Staff> staff(String keyword,Pageable pageable){
        return new JsonPage<Staff>(staffService.listStaff(keyword,pageable), pageable);
    }

    @GetMapping("/staff/{id}")
    Staff staff(@PathVariable String id){
        return staffService.findOne(id);
    }

    @PostMapping("/signUp")
    boolean signUp(String username,String password){
        if(username.equals("")||password.equals(""))
            return false;
        return staffService.signUp(username,password);
    }

}
